home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Development Tools & Languages / HyperCard Related / APDA HyperCard Toolkits / HyperCard Video Toolkit 2.0 / HVT #2 / Advanced Material / Video Sources / ticksToHMS.p < prev    next >
Encoding:
Text File  |  1995-02-07  |  1.6 KB  |  85 lines  |  [TEXT/MPS ]

  1. (*
  2.     ticksToHMS() -- Convert from HMS format to 1/60ths of a second
  3.  
  4.     To compile and link this file using Macintosh Programmer's Workshop,
  5.  
  6.         pascal -w ticksToHMS.p
  7.  
  8.         link -m ENTRYPOINT -o HyperCommands -rt XFCN=8001 -sn Main=ticksToHMS ∂
  9.             ticksToHMS.p.o "{MPW}"PLibraries:PasLib.o
  10.  
  11.     Copyright © 1988 Apple Computer, Inc.
  12.  
  13.     2/88 - Initial coding by Harry R. Chesley.
  14. *)
  15.  
  16. {$R-}
  17.  
  18. {$S ticksToHMS }     { Segment name must be the same as the command name. }
  19.  
  20. unit DummyUnit;
  21.  
  22. interface
  23.  
  24. uses MemTypes, QuickDraw, OSIntf, ToolIntf, HyperXCmd;
  25.  
  26. procedure EntryPoint(paramPtr: XCmdPtr);
  27.     
  28. implementation
  29.  
  30. type
  31.  
  32. Str31 = String[31];
  33.  
  34. procedure ticksToHMS(paramPtr: XCmdPtr); forward;
  35.  
  36. procedure EntryPoint(paramPtr: XCmdPtr);
  37.  
  38.     begin
  39.         ticksToHMS(paramPtr);
  40.     end;
  41.  
  42. procedure ticksToHMS(paramPtr: XCmdPtr);
  43.  
  44.     var t: longInt;
  45.         result: str255;
  46.  
  47.     {$I XCmdGlue.inc}
  48.  
  49.     procedure Fail(errMsg: Str255); { set theResult and quit }
  50.         begin
  51.             paramPtr^.returnValue := PasToZero(errMsg);
  52.             exit(ticksToHMS);
  53.         end;
  54.  
  55.     {$I VideoUtil.inc}
  56.  
  57.     procedure doDigits(value: longInt; index: integer);
  58.  
  59.         var str: str255;
  60.             c1, c2: char;
  61.  
  62.         begin
  63.             str := LongToStr(value);
  64.             if length(str) < 2 then c1 := '0'
  65.             else c1 := str[length(str)-1];
  66.             if length(str) < 1 then c2 := '0'
  67.             else c2 := str[length(str)];
  68.             result[index] := c1;
  69.             result[index+1] := c2;
  70.         end;
  71.  
  72.     begin
  73.         if paramPtr^.paramCount <> 1 then Fail('parameter count is not 1');
  74.  
  75.         result := 'xxxxxx';
  76.         t := GetLongParm(1);
  77.         doDigits((t div 216000) mod 100,1);
  78.         doDigits((t div 3600) mod 60,3);
  79.         doDigits((t div 60) mod 60,5);
  80.  
  81.         paramPtr^.returnValue := PasToZero(result);
  82.     end;
  83.  
  84. end.
  85.